package com.ias.agdis_r.fragment.task;

import com.ias.agdis_r.R;
import com.ias.agdis_r.activity.task.TaskInfoActivity;
import com.ias.agdis_r.adapter.FTaskListViewAdapter;
import com.ias.agdis_r.module.MessageModel;

import android.content.Intent;
import android.os.Bundle;
//import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

/**
 * 历史任务列表页面
 * @author guoxr
 *
 */
public class TaskTab02 extends Fragment {
	private ListView mListView;// 列表
	private FTaskListViewAdapter mAdapter;// 列表的适配器

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.task_flight_tab_02, container, false);
		setListAdapter(view);
		return view;
	}

	private void setListAdapter(View view) {
		// TODO Auto-generated method stub
		mListView = (ListView) view.findViewById(R.id.ListView);
		mAdapter = new FTaskListViewAdapter(getActivity()
				.getApplicationContext(), true, false);
		mListView.setAdapter(mAdapter);
		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(getActivity()
						.getApplicationContext(), TaskInfoActivity.class);
				intent.putExtra(MessageModel.TNB, mAdapter.getTNB(arg2));
				startActivity(intent);
			}
		});
	}
	
	/**
	 * 增加排序功能
	 * @param sortType
	 */
	public void sort(int sortType)
	{
		if(mAdapter!=null)
		{
			mAdapter.setSortType(sortType);
			mAdapter.notifyDataSetChanged();
		}
	}
}
